Repository navigation
fix(plugin-auth)!: a sign-up the email_domain posture admits by an invitation is not bound before its address is verified - #34969
Conversation
…vitation is not bound before its address is verified Under the email_domain audience posture with membershipPolicy 'auto', a self-serve sign-up whose address is off the allowlist and which a pending invitation addressed to it admitted is not bound into the deployment's organization while its address is unverified; it joins by accepting the invitation. isAdmittedByInvitationAlone decides which admitted sign-ups the request-scoped invitation admission covers, for invite_only and email_domain alike. An address on the allowlist is admitted by its domain and binds as before. Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…il_domain posture; changeset Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
…rites Claude-Session: https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 7 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a3aa4d291416b57bfe7e89be44f35e7244c5d41f && git checkout a3aa4d291416b57bfe7e89be44f35e7244c5d41f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin fff0ad0c180c08ac8de7db8499863bdfb69842e2 aea174380649ef644be6fdf068f05453079a715a && git checkout -B drift-repro fff0ad0c180c08ac8de7db8499863bdfb69842e2 && git merge --no-ff aea174380649ef644be6fdf068f05453079a715a
node scripts/docs-audit/affected-docs.mjs --json fff0ad0c180c08ac8de7db8499863bdfb69842e2
|
|
security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj The seat adopts the record below. It was rendered on this head at the contract-review tier by an isolated reviewer. Contract reviewServed-tier:
The reviewer did not run the full suites, dogfood, the workspace type check, the derived gates or CI. Scope: net diff ① Derived judgments
Findings
② Semver level
③ Boundary flags
④ Design judgmentOne pure decision, read by both postures and staged on the existing request-scoped record with the settle seams untouched, is the smallest correct shape. The cost is the S1 asymmetry, which is better fixed in the verdict (#34971) than by widening this rule. Implemented-by: VERDICT: PASS |
|
security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj 席位核对ACCEPT · head
|
…eives the declared self-registration set, and is refused when that set cannot be resolved (objectstack-ai#36312) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X8UqWLrzTYpuat8L5eLdf2c)_ Fixes objectstack-ai#34971 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no skill under `skills/**` teaches the audience posture's invitation sign-up or `selfRegistrationPermissionSet`; `content/docs/deployment/self-hosting.mdx` gains the rule in this change. Security-touching: yes repo:objectstack#4 · os-project-manager · session_01FEkQ5pb2t8Z8C64PkPyVt1 (dev executor, area a4-B; resumed from the released WIP `claude/issue-34971-allowlist-invite-grant@706e936`). ## 维护者速读 - 用户能看到什么变化:开放注册或按邮箱域名放行的自建部署里,被邀请的人自己注册后,和普通注册者一样拿到管理员指定给自助注册者的那组权限;若那组权限不存在或已停用,被邀请者注册也会被明确拒绝并提示去修配置。 - 为什么做:执行维护者对本单的裁决:被邀请与未被邀请的自助注册者只用一条规则,授权和入组读同一个判断,补上被邀请者少一组权限的漏洞。 - 出错会怎样:权限组配置坏掉的部署里,原本靠邀请仍能进来的人会被拒,直到管理员改好配置或直接为其建账号;没有任何账号会被多给权限;回滚即撤回本改动。 - 要你做什么:这是收紧注册权限的改动,需要你本人审阅、批准并亲手合并。L1 ACCEPT 7076000414,全量测试 4107 通过,契约 PASS 7076202877(座位 7,head ffffab1);两个小问题另立 objectstack-ai#36355 跟进。 ## What changes **The rule (ruling A, card comment 7063136215).** Under `open`, and under `email_domain` for an address on `allowedEmailDomains`, a self-serve sign-up is admitted by the posture's own rule whether or not it also holds a pending invitation. It receives the declared `selfRegistrationPermissionSet`, and when that set cannot be resolved it is refused `403 AUTH_CONFIG_ERROR`, like an uninvited sign-up. The invitation no longer admits it with no grant. - `packages/plugins/plugin-auth/src/audience-posture.ts`: a module-private `isAdmittedByPostureRule(audience, email)` (`open`: every address; `email_domain`: an address on the allowlist; `invite_only` and an invalid posture: none). `decideAudienceAdmission` reads it after the social-provider address rule and before the invitation carve-out, answering `grantPermissionSet: true`; `isAdmittedByInvitationAlone` reads it to answer false for an address the rule admits. The grant path in `auth-manager-membership-admission.ts` is unchanged: a verdict that asks for the set already refuses `AUTH_CONFIG_ERROR` when `selfRegistrationSetResolvable` answers false, so the invited sign-up now meets that refusal. The module doc's invitation carve-out and fail-posture paragraphs state the exception. - Unchanged (standing readings): under `invite_only` an invitation admits with no self-registration grant; under `email_domain` an off-allowlist sign-up an invitation admitted gets the account and no grant, whatever state the declared set is in; `admin_full_access` stays refused as the self-registration set; operator, bootstrap and provider creations. - `content/docs/deployment/self-hosting.mdx`: "admitted by its domain, invitation or not" now holds for the grant and the binding, and a new paragraph states the fail-closed refusal for both postures. - `packages/spec/src/migrations/entries/semantic/18.self-registration-permission-set-reaches-invited-sign-ups.ts`: the ADR-0087 D3 semantic entry (the one spec path), registered by the changeset's `registered` marker. - `packages/qa/dogfood/test/signup-organization-census-walled.dogfood.test.ts`: the open-posture invitee now holds the declared set on its first membership (the battery found the stale fixture). - `.changeset/34971-allowlist-invite-grant.md`: BREAKING, `Clause-②: no (narrowing)`, `Metadata-protocol: none`, `patch` on `@objectstack/plugin-auth` and `@objectstack/spec`. | posture | invited | address | before | after | |:---|:---|:---|:---|:---| | `invite_only` | yes (presented) | any | admit, no grant | same | | `email_domain` | yes | on list | admit, NO grant, bound | admit, GRANT, bound | | `email_domain` | yes | off list | admit, no grant, unbound until accept | same | | `open` | yes | any | admit, NO grant, bound | admit, GRANT, bound | | `open` / `email_domain` on list | no | | admit, grant, bound | same | | the two changed rows, declared set unresolvable | | | admitted ungranted | refused `AUTH_CONFIG_ERROR` (the narrowing) | ## Tests All readings under `scripts/pm/os-verify-lock.sh`, tree `objectstack-ai/objectstack`; the source of the change is unchanged from `ca290ccdc` to the head `ffffab1779` (the two later commits touch only test files). <details><summary>plugin-auth and spec (at ca290cc, after merging origin/main a5a5312)</summary> - `pnpm --filter @objectstack/plugin-auth test`: Test Files 291 passed (291); Tests 6204 passed, 10 skipped (6214); exit 0. The one red the WIP left (`presented-invitation.test.ts`, the `open` row) is rewritten here. - `pnpm --filter @objectstack/plugin-auth typecheck`: exit 0; `check:test-typecheck` OK (debt ledger held). - `pnpm --filter @objectstack/spec build`, `typecheck`, and `exec vitest run --maxWorkers=2 src/migrations` (5 files, 198 tests): all exit 0; the new entry reaches `registry.ts` and `dist/migrations/index.{js,mjs}`. - At `0ef10daa0b`: the three target files, `audience-posture.test.ts`, `invitation-acceptance-verified-address.test.ts`, `presented-invitation.test.ts`: 3 files, 152 tests passed. </details> <details><summary>Ablations (src read by relative import, no dist leg), restored to the HEAD blob fc4dbd6</summary> - M1, the subject of the new pins: `if (isAdmittedByPostureRule(audience, email))` mutated to `if (!hasPendingInvitation && isAdmittedByPostureRule(audience, email))` (the old order). Mutation landed (anchor 1 to 0, blob changed); 3 files: 9 failed, 143 passed. Red: the four invited unresolvable-set refusal rows (open and email_domain on the list, missing and switched off), the two invited verdict rows, the social on-list row, and the invited grant pins under email_domain on the list and under open. Restored: blob equals HEAD, `git diff HEAD` empty. - M2, the subject of the controls: the invitation-alone branch's `grantPermissionSet: false` mutated to `true`. 36 failed, 116 passed. Red include every CONTROL: the off-allowlist invited sign-up with a missing set, the off-allowlist and `invite_only` no-grant pins, and the `presented-invitation.test.ts` email_domain row. Restored: blob equals HEAD, `git diff HEAD` empty. </details> <details><summary>Dogfood battery (the title carries !)</summary> - At `0ef10daa0b`: closure build `pnpm --filter '@objectstack/dogfood^...' build` exit 0, then `pnpm --filter @objectstack/dogfood test`: Test Files 1 failed, 483 passed, 3 skipped (487); Tests 2 failed, 4105 passed, 68 skipped (4175). Both failures are one stale fixture this change makes false: `signup-organization-census-walled.dogfood.test.ts`, the grant-writer case under `group` and `isolated`, asserting the open-posture invitee holds no declared set. - Fixed in `ffffab1779` to the ruled behaviour (the invitee's declared grant settles on its first membership, the inviting organization). Rerun at `ffffab1779`: that file and its `single` sibling `signup-organization-census.dogfood.test.ts`, 2 files, 15 tests passed. The full battery was not rerun on the new head; the only change is that test file. </details> ## Acceptance notes - `boot-sign-in-reachability.ts` (outside this card's file surface) says `decideAudienceAdmission` short-circuits on `hasPendingInvitation` before the posture switch, admitting under every posture. It stays true of the switch; the posture-rule check now precedes the invitation, and under `open` / on-list `email_domain` with an unresolvable set an invitation no longer admits. Not edited here. Carried by objectstack-ai#36355 (with the `self-hosting.mdx` open-posture half-clause, contract review 7076202877 N1 and N3). - Dispatch and claim spell `Clause-②: no (narrowing)` (copied); the decision analysis 7062693710 suggested `yes (narrowing)` for a diff that widens who receives the set and narrows the unresolvable case. Left for the contract review. - The dispatch asked for an ADR-0087 migration entry; objectstack-ai#34969 and objectstack-ai#35200 used `not-required (no-migration-prescription)` instead. This change registers a semantic entry, so `os migrate meta` and the upgrade guide carry the notice. ## Verification <details><summary>Dispatch-gate families at ffffab1</summary> - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` over 8 changed paths: 115 families, each run with its exit code recorded before any pipe; `--ran` reconciliation: 115 derived, 115 run, 0 NOT-MEASURED, 0 UNRUN, every one exit 0. - On the first pass (at `ca290ccdc`) `check:test-source-alias` was red on the edited `presented-invitation.test.ts` (collection reaches the dynamic import of `@objectstack/core/egress`); fixed by the module-top import its two sibling test files carry (`0ef10daa0b`). - `check:adr-0087-registration`: the changeset is `[BREAKING+bang+clause-②-narrowing]`, `registered self-registration-permission-set-reaches-invited-sign-ups (new here)`. - `overlap-check` before each push: clean against origin/main and objectstack-ai#35129 (shares `self-hosting.mdx`, merges cleanly). - Local-only `check:dev-prereqs`: exit 1, the box's workspace is not fully built (35 `ui/` and other dists absent); a machine-state reading, not about this diff. </details> **Read first (by risk):** `audience-posture.ts` `decideAudienceAdmission` (the new `isAdmittedByPostureRule` branch ahead of `if (hasPendingInvitation)`); `isAdmittedByInvitationAlone`; the new `it.each` refusal pins in `audience-posture.test.ts` (end-of-chain describe). **Two-minute check:** `pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/audience-posture.test.ts src/invitation-acceptance-verified-address.test.ts src/presented-invitation.test.ts` — expect 3 files green. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5pb2t8Z8C64PkPyVt1 <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill under
skills/**teaches theemail_domainposture's invitation sign-up;content/docs/deployment/self-hosting.mdxgains the rule in this change.维护者速读
email_domain准入模式、membershipPolicy: 'auto'下,邮箱域名不在白名单、凭发给该地址的待处理邀请注册的账号,邮箱验证前不加入默认组织;验证后接受邀请时按邀请写入成员关系。invite_only与email_domain现在读同一个判定isAdmittedByInvitationAlone。白名单内的地址(有无邀请)照旧在创建时绑定。invite_only已有的「邀请注册验证前不绑定」规则扩展到email_domain:邀请只按注册时填写的地址匹配,不能证明持有该邮箱。email_domain部署,改为验证邮箱后接受邀请,或由平台管理员用 Add Member 挂接。回滚即 revert 本 PR。packages/plugins/plugin-auth/src/audience-posture.ts的isAdmittedByInvitationAlone(判定本身);auth-manager-membership-admission.ts的validateAudienceAdmission(暂存点改读该判定);invitation-acceptance-verified-address.test.ts新增的email_domaindescribe。pnpm --filter @objectstack/plugin-auth exec vitest run src/invitation-acceptance-verified-address.test.ts src/audience-posture.test.ts,预期 2 个文件、108 个用例全绿。email_domain见 Acceptance notes)。What changes
The rule. Under the
email_domainaudience posture withmembershipPolicy: 'auto', a self-serve sign-up whose address is off the allowlist, admitted by a pending invitation addressed to it, is not bound into the deployment's organization while its address is unverified. It joins by accepting the invitation once the address is verified, which writes the membership the invitation names, or through a platform administrator's Add Member. Verifying the address binds nothing by itself. This is the rule that holds underinvite_onlyfor a sign-up admitted by the invitation it presents, carried by the same request-scoped admission.packages/plugins/plugin-auth/src/audience-posture.ts:isAdmittedByInvitationAlone({ audience, creationClass, email, proof, hasPendingInvitation })is the one decision both postures read.invite_only: a self-serve sign-up that presented its invitation.email_domain: a self-serve sign-up off the allowlist that a pending invitation admitted.open, an off-vocabulary posture, and every creation that is not self-serve: never. The module doc's invitation carve-out section states it.auth-manager-membership-admission.ts:validateAudienceAdmissionstages the request-scoped invitation admission (stageInvitationAdmission, unchanged) when that decision answers yes; the invitation proof it computed is kept for the decision.settleMembershipand both settle seams are unchanged; the docblock and the info line name the widened rule.auth-manager.ts: docblocks of the request-scoped admission store name the widened rule. No new mechanism.invite_onlyandopenpostures.tenancy-modes.mdx,environment-variables.mdx(OS_AUTH_MEMBERSHIP_POLICY),permissions/authentication.mdxandself-hosting.mdxstate that the binding rule coversemail_domain..changeset/email-domain-invitation-sign-up-unbound-until-verified.md,@objectstack/plugin-authpatch, BREAKING,adr-0087: not-required (no-migration-prescription).email_domaininvitation sign-up (every test file namingemail_domainwas read; the full plugin-auth suite passes unchanged), so none moved.No spec, schema, stored row, route path, error code or exported signature of a published entry changes.
Tests
src/invitation-acceptance-verified-address.test.ts(realAuthManagerover@objectstack/driver-sqlon sqlite:memory:, driven throughAuthManager.handleRequest), a new top-level describe, 7 cases:src/audience-posture.test.ts:isAdmittedByInvitationAlone, 4 cases (off the allowlist with an invitation; on the allowlist with or without one;invite_onlypresented, address and none; no invitation, operator and provider classes,openand an off-vocabulary posture).Acceptance notes
invite_onlyaudience posture withmembershipPolicy: 'auto', a sign-up admitted by the invitation it presents is not bound while its email address is unverified." This PR extends the rule toemail_domain, so that sentence, its status-line summary ("D1 and D7: under theinvite_onlyaudience posture, a sign-up admitted by the invitation it presents is not bound while its email address is unverified") and its D7 ledger row ("Invitation sign-up, address unverified (invite_only)") need widening to name theemail_domaincase: a sign-up off the allowlist that an invitation addressed to it admitted. The enforcement pointer (settleMembership) stays correct.docs/adr/**is not edited here.email_domain, an address on the allowlist that also holds a pending invitation is admitted bydecideAudienceAdmission's invitation branch, which precedes the domain switch (read from the code, not measured: that branch grants no self-registration permission set). The domain rule admits that address on its own, so this PR treats it as domain-admitted for binding: it binds as before, per the ruling's scope, and the rule is not widened to it. The on-allowlist control pins both the uninvited and the invited case.email_domain.Verification
Head
aea1743806: the code commit, a merge oforigin/mainat28a733e55f(d59d48e8df), and two docs commits after it. The code is the same atd59d48e8dfandaea1743806; the last commit rewords one sentence ofself-hosting.mdx.Target pins and package suite
pnpm --filter @objectstack/plugin-auth exec vitest run src/invitation-acceptance-verified-address.test.ts src/audience-posture.test.tsataea1743806: Test Files 2 passed (2), Tests 108 passed (108).@objectstack/plugin-authfull suite atd59d48e8df: Test Files 285 passed (285), Tests 5980 passed, 10 skipped.@objectstack/runtime: not run locally. No helper that runtime tests import moved (audience-gate-test-support.tsand@objectstack/verifyare untouched), and no runtime test names theemail_domainposture; CI's Test Core runs it.Workspace type check
pnpm turbo run typecheck --filter='...@objectstack/plugin-auth' --concurrency=2(plugin-auth and every package that depends on it, with their builds) atd59d48e8df: Tasks 133 successful, 133 total, exit 0.Derived gates: 107 of 107 run, every exit code recorded
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 107 families atd59d48e8df, and the same 107 ataea1743806. All 107 ran. 104 exited 0 on the first run.check:skill-examplesandcheck:dual-build-cjs-loadsanswered exit 3 (prerequisite: some packages'distnot built) and exit 0 once built.check:role-wordexited 1 on a reserved word in the newself-hosting.mdxsentence;aea1743806rewords it and the gate exits 0. The 41 doc, changeset and link families were run again ataea1743806: 41 exited 0.--ranreconciliation: 107 derived, 107 run, 0 NOT-MEASURED, every exit code recorded.Ablations: red, then restored
Each mutation through
scripts/ablation-replace.mjs(anchor hit once), against the two target files, 108 cases:email_domainarm ofisAdmittedByInvitationAloneanswering no: 4 of 108 red, the three door cases of the new describe and the unit case for an address off the allowlist. Restored: blob equal toHEAD,git diff HEADempty.email_domainsign-up: 2 of 108 red, the on-allowlist control and its unit case. Restored: blob equal toHEAD,git diff HEADempty.Dogfood battery
The title carries
!, so the battery ran once ataea1743806, CI's command (dependency closure built,pnpm --filter @objectstack/dogfood testunder the verify lock): Test Files 479 passed, 3 skipped (482); Tests 4072 passed, 68 skipped (4140); exit 0.Generated by Claude Code